<template>
    <view class="doctor">
        <Navigation title="我的医生" background="#fff" />
        <view class="search ph-32 pv-12 h-88">
            <view class="w-686 h-64 search-box">
                <u-search
                    placeholder="请输入您想要搜索的内容"
					v-model="listParams.keyword"
                    bgColor="#F5F5F5"
                    height="32"
                    :showAction="false"
                    searchIconColor="#CCCCCC"
                    placeholderColor="#CCCCCC"
                    :clearabled="false"
					@search="handleSearch"
                ></u-search>
                <view class="text fs-30 text-color4 w-108" @click.stop="handleSearch">搜索</view>
            </view>
        </view>
        <scroll-view scroll-y="true" class="list ph-20" :style="{ height: height + 'px' }">
            <view class="mt-20 list-box b-24 f jc-s-b ph-28 pv-28" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
                   <image :src="item.avatar" class="w-120 h-120 b-12 mr-20"></image>
                <view class="f f1 fd-c">
                    <view class="f jc-s-b ai-c">
                        <view class="f ai-c">
                            <view class="fs-30 fw-600 text-color4 mr-12">{{ item.name }}</view>
                            <view class="fs-20 w-52 h-28 ai-c jc-c mr-8 b-4 voice" v-show="item.voiceConsultation">语音</view>
                            <view class="fs-20 w-52 h-28 ai-c jc-c mr-8 b-4 imageText" v-show="item.imageConsultation">图文</view>
                            <view class="fs-20 w-52 h-28 ai-c jc-c b-4 tel" v-show="item.phoneConsultation">电话</view>
                        </view>
                        <view class="w-158 h-56 b-56 f ai-c jc-c ask" v-show="item.onlineStatus == 1">
                            <image src="http://cwht.ricecs.cn/app/index/ask.png" class="w-24 h-24 mr-8"></image>
                            <view class="fs-26 text-color5">问医生</view>
                        </view>
                        <view class="w-158 h-56 b-56 f ai-c jc-c rest" v-show="item.onlineStatus != 1">
                            <image src="http://cwht.ricecs.cn/app/index/rest.png" class="w-24 h-24 mr-8"></image>
                            <view class="fs-26 text-color3">休息中</view>
                        </view>
                    </view>
                    <view class="f mt-12">
                        <view class="fs-26 text-color2 mr-8">评分</view>
                        <view class="fs-26 fw-600 text-color mr-24">{{item.scores||0}}</view>
                        <view class="fs-26 text-color2 mr-8">累计接诊</view>
                        <view class="fs-26 fw-600 text-color mr-24">{{item.orderNum||0}}</view>
                    </view>
                    <view class="fs-24 text-color4 text-ellipsis-1 mt-12">{{ item.labelNames }}</view>
                    <view class="mt-12 f ai-c">
                        <view class="fs-24 text-color3">执业编号：</view>
                        <view class="fs-24 text-color4">{{ item.licenseNo }}</view>
                    </view>
                    <view class="mt-12 f ai-c">
                        <view class="fs-24 text-color3">执擅长：</view>
                        <view class="fs-24 text-color4">{{ item.skillingRemark }}</view>
                    </view>
                </view>
            </view>
        </scroll-view>
    </view>
</template>
<script setup lang="ts">

import { ref } from 'vue';
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { doctorPage,matchDoctor } from '@/services/api/index/index';
import { dictDataType } from '@/services/api/dict';
const list = ref<any[]>([]);
const listParams = ref<any>({
    pageNo: 1,
    pageSize: 10,
    keyword: '',

});
const departmentList = ref<any[]>([]);
const departmentText = ref([]);
const departmentCurt = ref(0);
const consultList = ['筛选', '图文咨询', '语音咨询', '视频咨询'];
const curt = ref<number | null>(null);
onShow(() => {
    list.value = [];
    listParams.value.pageNo = 1;
    getList();
    getDictDataType();
});
async function getDictDataType() {
    const { data } = await dictDataType({ type: 'common_doctor_dept' });
    departmentList.value = data;
    departmentText.value = data.map((item: any) => {
        return item.label;
    });
}
async function getList() {
    const { data } = await matchDoctor(listParams.value);
    uni.stopPullDownRefresh();
    list.value = list.value.concat(data.list);

}
function handleSearch() {

    list.value = [];
    listParams.value.pageNo = 1;
    getList();
}
function selectDepartment() {
    uni.showActionSheet({
        itemList: departmentText.value,
        success: function (res: any) {
            departmentCurt.value = res.tapIndex;
            listParams.value.department = departmentList.value[departmentCurt.value].id;
            list.value = [];
            listParams.value.pageNo = 1;
            getList();
        },
    });
}
function handleScreen() {
    uni.showActionSheet({
        itemList: consultList,
        success: function (res: any) {
            curt.value = res.tapIndex;
            if (curt.value == 0) {
                listParams.value.imageConsultation = null;
                listParams.value.voiceConsultation = null;
                listParams.value.phoneConsultation = null;
            } else if (curt.value == 1) {
                listParams.value.imageConsultation = true;
                listParams.value.voiceConsultation = null;
                listParams.value.phoneConsultation = null;
            } else if (curt.value == 2) {
                listParams.value.imageConsultation = null;
                listParams.value.voiceConsultation = true;
                listParams.value.phoneConsultation = null;
            } else if (curt.value == 3) {
                listParams.value.imageConsultation = null;
                listParams.value.voiceConsultation = null;
                listParams.value.phoneConsultation = true;
            }
            list.value = [];
            listParams.value.pageNo = 1;
            getList();
        },
    });
}
function toDetail(data: any) {
    uni.navigateTo({
        url: `/pages_index/doctorDetail?id=${data.id}`,
    });
}
//下拉刷新
onPullDownRefresh(() => {
    list.value = [];
    listParams.value.pageNo = 1;
    getList();
});
//上拉加载
onReachBottom(() => {
    listParams.value.pageNo++;
    getList();
});
let systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
let pageHeight = systemInfo.windowHeight;
const height = pageHeight - statusBarHeight - 46 - 43;
</script>
<style lang="scss" scoped>
.doctor {
    background: #f5f5f5;
    min-height: 100vh;
    .list {
        .list-box {
            background: #fff;
            .ask {
                background: #fabb3c;
            }
            .rest {
                background: #f0f0f0;
            }
            .voice {
                background: #fff9e6;
                color: #fac519;
                text-align: center;
            }
            .imageText {
                background: #f0f2f5;
                color: #5769a0;
                text-align: center;
            }
            .tel {
                background: #edf2ff;
                color: #4974f5;
                text-align: center;
            }
        }
    }
    .screen {
        background: #fff;
    }
    .search {
        background: #fff;
        .search-box {
            position: relative;
            .text {
                position: absolute;
                right: 0rpx;
                top: 11rpx;
                z-index: 1;
                text-align: center;
            }
            .text::after {
                content: '';
                position: absolute;
                left: 0rpx;
                top: 7rpx;
                width: 1px;
                height: 32rpx;
                background: #dddddd;
            }
        }
    }
    ::v-deep .u-search__content {
        border-radius: 8rpx !important;
    }
}
</style>
